# Generic Makefile

SHELL = /bin/sh

.SUFFIXES:
.SUFFIXES: .c .o

# Common prefix 
PREFIX = /usr/local

# Lua 5.1 config
#LUAINC = $(PREFIX)/include/lua51
#LUALIB = $(PREFIX)/lib
#LLIB = lua5.1

## LuaJIT2
LUAINC = $(PREFIX)/include/luajit-2.0
LUALIB = $(PREFIX)/lib
LLIB = luajit-5.1

SRCDIR = src
OBJDIR = obj

# basic setup
CC = gcc
WARN = -pedantic -ansi -std=c89
INCS = -I$(PREFIX)/include -I$(LUAINC)
LIBS = -L$(PREFIX)/lib -L$(LUALIB) -lm -lpthread -lfcgi -l$(LLIB)
#DEBUG = -ggdb 
OPTS = -O2
#OPTS = -O3 -march=native
CFLAGS = $(INCS) $(WARN) $(OPTS) $(DEBUG) $G
LDFLAGS = $(LIBS) $(OPTS) $(DEBUG)

VPATH = $(SRCDIR)/

SOURCES = main.c config.c pool.c buffer.c request.c
OBJECTS = $(SOURCES:%.c=%.o)
EXEC = luafcgid
	
all: $(VPATH)$(SOURCES) $(EXEC)

$(EXEC): $(OBJECTS)
	$(CC) $(LDFLAGS) $(OBJECTS) -o $@

clean:
	rm -f $(OBJECTS) $(EXEC)

docs:
	cd ../docs; $(MAKE)



